package com.tangding.service.db;

import java.io.Serializable;
import java.util.List;

import com.tangding.common.cache.CacheTrigger;
import com.tangding.common.cache.TriggerCachePool;
import com.tangding.common.exception.GException;
import com.tangding.common.logx.LogHelp;

/**
 * @description 
 *
 * @author Ranger
 * @version 2017年9月26日_下午3:22:45
 *
 */
public abstract class TriggerCacheMongoRepository<T, ID extends Serializable> extends BaseMongoRepository<T, ID>{
	TriggerCachePool pool = new TriggerCachePool(1, 10, true, new CacheTrigger() {
		
		@Override
		public Object doTrigger(Object event) {
			try {
				saveMany((List) event);
			} catch (GException e) {
				LogHelp.doLogException(e);
			}
			return null;
		}
	});
	
	public void pushLog(T log) {
		pool.addEvent(log);
	}
}
